<template>
  <RouterView />
</template>
<script setup lang="ts">
import { Notify, useQuasar } from 'quasar'
import { onMounted } from 'vue';
import { checkVersion } from './utils/versionUtils';

Notify.setDefaults({
  badgeStyle: 'background-color: blue; color: white;'
})

const $q = useQuasar()

onMounted(async ()=>{
  const res = await checkVersion()
  // if (res == false){
  //   $q.notify({
  //     message: 'Your version is outdated. Please refresh the page.',
  //     position: 'bottom-right',
  //     timeout: 10000,
  //     actions: [
  //       { label: 'Refresh', color: 'white', handler: () => reloadWebsite()},
  //     ]
  //   })
  // }
})

function reloadWebsite(){
  const urlSearchParams = new URLSearchParams(window.location.search);
  urlSearchParams.set('timestamp', Date.now().toString());
  const newUrl = new URL(window.location.href);
  newUrl.search = urlSearchParams.toString();
  window.location.href = newUrl.toString();
}

</script>

<style scoped></style>
